﻿/* Converted to D from hge.h by htod */

/*
** Haaf's Game Engine 1.54
** Copyright (C) 2003-2004, Relish Games
** hge.relishgames.com
**
** System layer API
*/

module core.hge;


const HGE_VERSION = 0x160;

/*
** Common data types
*/

typedef ulong						HWND;
/*
** Common math constants
*/


const M_PI = 3.14159265358979323846f;
const M_PI_2 = 1.57079632679489661923f;
const M_PI_4 = 0.785398163397448309616f;
const M_1_PI = 0.318309886183790671538f;
const M_2_PI = 0.636619772367581343076f;


/*
** HGE* Handle types
*/

typedef uint HTEXTURE;
typedef uint HTARGET;
typedef uint HEFFECT;
typedef uint HMUSIC;
typedef uint HSTREAM;
typedef uint HCHANNEL;

/*
** Hardware color macros
*/



/*
** HGE* Blending constants
*/

const BLEND_COLORADD = 1;
const BLEND_COLORMUL = 0;
const BLEND_ALPHABLEND = 2;
const BLEND_ALPHAADD = 0;
const BLEND_ZWRITE = 4;
const BLEND_NOZWRITE = 0;

const BLEND_DEFAULT	=	BLEND_COLORMUL | BLEND_ALPHABLEND | BLEND_NOZWRITE;
const BLEND_DEFAULT_Z	=	BLEND_COLORMUL | BLEND_ALPHABLEND | BLEND_ZWRITE;
/*
** HGE* System state constants
*/

enum hgeBoolState
{
    HGE_WINDOWED = 11,
    HGE_ZBUFFER,
    HGE_TEXTUREFILTER,
    HGE_USESOUND = 18,
    HGE_DONTSUSPEND = 24,
    HGE_HIDEMOUSE,
    HGE_BOOLSTATE_FORCE_DWORD = 2147483647,
}


enum hgeFuncState
{
    HGE_FRAMEFUNC = 1,
    HGE_RENDERFUNC,
    HGE_FOCUSLOSTFUNC,
    HGE_FOCUSGAINFUNC,
    HGE_EXITFUNC,
    HGE_FUNCSTATE_FORCE_DWORD = 2147483647,
}



enum hgeHwndState
{
    HGE_HWND = 26,
    HGE_HWNDPARENT,
    HGE_HWNDSTATE_FORCE_DWORD = 2147483647,
}

enum hgeIntState
{
    HGE_SCREENWIDTH = 8,
    HGE_SCREENHEIGHT,
    HGE_SCREENBPP,
    HGE_SAMPLERATE = 19,
    HGE_FXVOLUME,
    HGE_MUSVOLUME,
    HGE_FPS = 23,
    HGE_INTSTATE_FORCE_DWORD = 134217727,
}



enum hgeStringState
{
    HGE_ICON = 6,
    HGE_TITLE,
    HGE_INIFILE = 15,
    HGE_LOGFILE,
    HGE_STRINGSTATE_FORCE_DWORD = 2147483647,
}

/*
** Callback protoype used by HGE*
*/


extern(C){
 typedef bool function()	hgeCallback;
}
/*
** HGE_FPS system state special constants
*/


const HGE_FPS_UNLIMITED = 0;
const HGE_FPS_VSYNC = -1;

/*
** HGE* Primitive type constants
*/

const HGE_PRIM_POINT 	= 1;
const HGE_PRIM_LINES 	= 2;
const HGE_PRIM_TRIPLES	= 3;
const HGE_PRIM_QUADS 	= 4;

/*
** HGE* Vertex structure
*/



struct hgeVertex
{
    float x;
    float y;
    float z;
    uint col;
    float tx;
    float ty;
}


/*
** HGE* Triple structure
*/



struct hgeTriple
{
    hgeVertex [3]v;
    uint tex;
    int blend;
}


/*
** HGE* Quad structure
*/


struct hgeQuad
{
    hgeVertex 	[4]v;
	HTEXTURE	tex;
    int 		blend= BLEND_DEFAULT;

	static	hgeQuad	opCall(float x,float y, float w,float h, uint color= 0xffffffff)
	{
		float tempx1, tempy1, tempx2, tempy2;
		hgeQuad	 quad;
	
		tempx1 = x;
		tempy1 = y;
		tempx2 = x+w;
		tempy2 = y+h;

		quad.v[0].x = tempx1; quad.v[0].y = tempy1;
		quad.v[1].x = tempx2; quad.v[1].y = tempy1;
		quad.v[2].x = tempx2; quad.v[2].y = tempy2;
		quad.v[3].x = tempx1; quad.v[3].y = tempy2;

		quad.v[0].z = 
		quad.v[1].z = 
		quad.v[2].z = 
		quad.v[3].z = 0.5f;
		
		quad.v[0].col = 
		quad.v[1].col = 
		quad.v[2].col = 
		quad.v[3].col = color;

		return quad;
	}
}


/*
** HGE* Input Event structure
*/



struct hgeInputEvent
{
    int type;
    int key;
    int flags;
    int chr;
    int wheel;
    float x;
    float y;
}


/*
** HGE* Input Event type constants
*/


const INPUT_KEYDOWN 	= 1;
const INPUT_KEYUP 		= 2;
const INPUT_MBUTTONDOWN	= 3;
const INPUT_MBUTTONUP 	= 4;
const INPUT_MOUSEMOVE 	= 5;
const INPUT_MOUSEWHEEL	= 6;

/*
** HGE* Input Event flags
*/


const HGEINP_SHIFT 	= 1;
const HGEINP_CTRL 		= 2;
const HGEINP_ALT 		= 4;
const HGEINP_CAPSLOCK 	= 8;
const HGEINP_SCROLLLOCK = 16;
const HGEINP_NUMLOCK 	= 32;
const HGEINP_REPEAT 	= 64;





/*
** HGE* Virtual-key codes
*/

const HGEK_LBUTTON = 0x01;
const HGEK_RBUTTON = 0x02;
const HGEK_MBUTTON = 0x04;

const HGEK_ESCAPE = 0x1B;
const HGEK_BACKSPACE = 0x08;
const HGEK_TAB = 0x09;
const HGEK_ENTER = 0x0D;
const HGEK_SPACE = 0x20;

const HGEK_SHIFT = 0x10;
const HGEK_CTRL = 0x11;
const HGEK_ALT = 0x12;

const HGEK_LWIN = 0x5B;
const HGEK_RWIN = 0x5C;
const HGEK_APPS = 0x5D;

const HGEK_PAUSE = 0x13;
const HGEK_CAPSLOCK = 0x14;
const HGEK_NUMLOCK = 0x90;
const HGEK_SCROLLLOCK = 0x91;

const HGEK_PGUP = 0x21;
const HGEK_PGDN = 0x22;
const HGEK_HOME = 0x24;
const HGEK_END = 0x23;
const HGEK_INSERT = 0x2D;
const HGEK_DELETE = 0x2E;

const HGEK_LEFT = 0x25;
const HGEK_UP = 0x26;
const HGEK_RIGHT = 0x27;
const HGEK_DOWN = 0x28;

const HGEK_0 = 0x30;
const HGEK_1 = 0x31;
const HGEK_2 = 0x32;
const HGEK_3 = 0x33;
const HGEK_4 = 0x34;
const HGEK_5 = 0x35;
const HGEK_6 = 0x36;
const HGEK_7 = 0x37;
const HGEK_8 = 0x38;
const HGEK_9 = 0x39;


const HGEK_A = 0x41;
const HGEK_B = 0x42;
const HGEK_C = 0x43;
const HGEK_D = 0x44;
const HGEK_E = 0x45;
const HGEK_F = 0x46;
const HGEK_G = 0x47;
const HGEK_H = 0x48;
const HGEK_I = 0x49;
const HGEK_J = 0x4A;
const HGEK_K = 0x4B;
const HGEK_L = 0x4C;
const HGEK_M = 0x4D;
const HGEK_N = 0x4E;
const HGEK_O = 0x4F;
const HGEK_P = 0x50;
const HGEK_Q = 0x51;
const HGEK_R = 0x52;
const HGEK_S = 0x53;
const HGEK_T = 0x54;
const HGEK_U = 0x55;
const HGEK_V = 0x56;
const HGEK_W = 0x57;
const HGEK_X = 0x58;
const HGEK_Y = 0x59;
const HGEK_Z = 0x5A;


const HGEK_GRAVE		= 0xC0;
const HGEK_MINUS		= 0xBD;
const HGEK_EQUALS		= 0xBB;
const HGEK_BACKSLASH	= 0xDC;
const HGEK_LBRACKET	= 0xDB;
const HGEK_RBRACKET	= 0xDD;
const HGEK_SEMICOLON	= 0xBA;
const HGEK_APOSTROPHE	= 0xDE;
const HGEK_COMMA		= 0xBC;
const HGEK_PERIOD		= 0xBE;
const HGEK_SLASH		= 0xBF;


const HGEK_NUMPAD0	= 0x60;
const HGEK_NUMPAD1	= 0x61;
const HGEK_NUMPAD2	= 0x62;
const HGEK_NUMPAD3	= 0x63;
const HGEK_NUMPAD4	= 0x64;
const HGEK_NUMPAD5	= 0x65;
const HGEK_NUMPAD6	= 0x66;
const HGEK_NUMPAD7	= 0x67;
const HGEK_NUMPAD8	= 0x68;
const HGEK_NUMPAD9	= 0x69;

const HGEK_MULTIPLY	= 0x6A;
const HGEK_DIVIDE		= 0x6F;
const HGEK_ADD			= 0x6B;
const HGEK_SUBTRACT	= 0x6D;
const HGEK_DECIMAL		= 0x6E;

const HGEK_F1			= 0x70;
const HGEK_F2			= 0x71;
const HGEK_F3			= 0x72;
const HGEK_F4			= 0x73;
const HGEK_F5			= 0x74;
const HGEK_F6			= 0x75;
const HGEK_F7			= 0x76;
const HGEK_F8			= 0x77;
const HGEK_F9			= 0x78;
const HGEK_F10			= 0x79;
const HGEK_F11			= 0x7A;
const HGEK_F12			= 0x7B;